Skip to content

feat(CategoryTheory/Sites): local sites#41083

Open
peabrainiac wants to merge 22 commits into
leanprover-community:masterfrom
peabrainiac:localSites
Open

feat(CategoryTheory/Sites): local sites#41083
peabrainiac wants to merge 22 commits into
leanprover-community:masterfrom
peabrainiac:localSites

Conversation

@peabrainiac

@peabrainiac peabrainiac commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

A local site is a site with a terminal object whose only covering sieve is the trivial one. We define local sites, construct a functor coconstantSheaf on them that is right-adjoint to the global sections functor, and prove that this functor and hence also the constant sheaf functor are fully faithful.


A previous iteration of this was in #22817 already, but never got merged; this PR is based not directly on that version but on https://peabrainiac.github.io/lean-catdg/docs/CatDG/ForMathlib/LocalSite.html which I had developed a bit more since. Not all features from that file are included here to keep the PR small (in particular, I've left out the construction of the localTopology and proof that a site is local iff it is contained in that), but I did include some naming changes and IsLocalSite.tfae which was not in the previous PR.

Another difference is that Presheaf.coconst is now constructed explicitly instead of as a composition of several standard functors. @chrisflav I briefly asked you about this earlier, and you said that you preferred the construction as a composition, but after trying both approaches I came to the conclusion that the explicit approach is a lot more workable - the reason for this is that Presheaf.coconst.obj A sends each object X of the site to the type of functions (⊤_ C ⟶ X) → A, and it is important to be able to work with these functions explicitly. Defining Presheaf.coconst in terms of yoneda and coyoneda previously worked for this because morphism types in Type were defeq to function types, but since a recent refactor they aren't anymore, which adds yet another source of friction in addition to the two ULifts that that definition inserts. I think even though that definition was elegant/nice, it is more important that Presheaf.coconst evaluates up to defeq to types of functions and not morphism types involving two ULifts.

Open in Gitpod

@peabrainiac peabrainiac added the t-category-theory Category theory label Jun 26, 2026
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown

PR summary 335f3bdcb4

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.CategoryTheory.Sites.LocalSite (new file) 1177

Declarations diff (regex)

+ GrothendieckTopology.IsLocalSite
+ coconstantSheaf
+ coconstantSheafΓNatIsoId
+ constantΓCoconstantTriple
+ coproductUniqueIso_hom
+ coproductUniqueIso_inv
+ faithful_constantSheaf
+ from_terminal_mem_of_mem
+ full_constantSheaf
+ fullyFaithfulCoconstantSheaf
+ fullyFaithfulConstantSheaf
+ instance (A : Type u') [Category.{v', u'} A] [HasColimitsOfSize.{v, v, v', u'} A]
+ instance : (coconstantSheaf.{w} J A).Faithful
+ instance : (coconstantSheaf.{w} J A).Full
+ instance : (coconstantSheaf.{w} J A).IsRightAdjoint
+ instance {C : Type u} [Category.{v} C] [HasTerminal C] : (trivial C).IsLocalSite
+ point
+ pointPresheafFiberIso
+ pointPresheafFiberIso_naturality
+ pointPresheafFiberNatIso
+ pointSheafFiberIso
+ productUniqueIso_hom
+ productUniqueIso_inv
+ productUniqueIso_inv_π
+ shrinkCoyoneda_obj_map
+ shrinkYoneda_obj_map
+ toPresheafFiber_pointPresheafFiberIso_hom
+ ΓCoconstantSheafAdj
+ Γ_isLeftAdjoint
+ ι_coproductUniqueIso_hom
++ instance {C : Type u} [Category.{v} C] (J : GrothendieckTopology C) [J.IsLocalSite]

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean)

Lean-aware diff — post-build, computed from the Lean environment (commit 335f3bd).

  • +39 new declarations
  • −0 removed declarations
+CategoryTheory.GrothendieckTopology.IsLocalSite
+CategoryTheory.GrothendieckTopology.IsLocalSite.casesOn
+CategoryTheory.GrothendieckTopology.IsLocalSite.coconstantSheaf
+CategoryTheory.GrothendieckTopology.IsLocalSite.coconstantSheafΓNatIsoId
+CategoryTheory.GrothendieckTopology.IsLocalSite.constantΓCoconstantTriple
+CategoryTheory.GrothendieckTopology.IsLocalSite.eq_top_of_mem
+CategoryTheory.GrothendieckTopology.IsLocalSite.faithful_constantSheaf
+CategoryTheory.GrothendieckTopology.IsLocalSite.from_terminal_mem_of_mem
+CategoryTheory.GrothendieckTopology.IsLocalSite.full_constantSheaf
+CategoryTheory.GrothendieckTopology.IsLocalSite.fullyFaithfulCoconstantSheaf
+CategoryTheory.GrothendieckTopology.IsLocalSite.fullyFaithfulConstantSheaf
+CategoryTheory.GrothendieckTopology.IsLocalSite.instFaithfulSheafCoconstantSheaf
+CategoryTheory.GrothendieckTopology.IsLocalSite.instFaithfulSheafConstantSheafOfHasColimitsOfSizeOfHasProducts
+CategoryTheory.GrothendieckTopology.IsLocalSite.instFullSheafCoconstantSheaf
+CategoryTheory.GrothendieckTopology.IsLocalSite.instFullSheafConstantSheafOfHasColimitsOfSizeOfHasProducts
+CategoryTheory.GrothendieckTopology.IsLocalSite.instIsLeftAdjointSheafΓOfHasColimitsOfSizeOfHasProducts
+CategoryTheory.GrothendieckTopology.IsLocalSite.instIsRightAdjointSheafCoconstantSheaf
+CategoryTheory.GrothendieckTopology.IsLocalSite.instTrivialOfHasTerminal
+CategoryTheory.GrothendieckTopology.IsLocalSite.mk
+CategoryTheory.GrothendieckTopology.IsLocalSite.point
+CategoryTheory.GrothendieckTopology.IsLocalSite.point.congr_simp
+CategoryTheory.GrothendieckTopology.IsLocalSite.pointPresheafFiberIso
+CategoryTheory.GrothendieckTopology.IsLocalSite.pointPresheafFiberIso_naturality
+CategoryTheory.GrothendieckTopology.IsLocalSite.pointPresheafFiberIso_naturality_assoc
+CategoryTheory.GrothendieckTopology.IsLocalSite.pointPresheafFiberNatIso
+CategoryTheory.GrothendieckTopology.IsLocalSite.pointSheafFiberIso
+CategoryTheory.GrothendieckTopology.IsLocalSite.rec
+CategoryTheory.GrothendieckTopology.IsLocalSite.recOn
+CategoryTheory.GrothendieckTopology.IsLocalSite.toHasLimitsOfShape
+CategoryTheory.GrothendieckTopology.IsLocalSite.toPresheafFiber_pointPresheafFiberIso_hom
+CategoryTheory.GrothendieckTopology.IsLocalSite.toPresheafFiber_pointPresheafFiberIso_hom_assoc
+CategoryTheory.GrothendieckTopology.IsLocalSite.ΓCoconstantSheafAdj
+CategoryTheory.GrothendieckTopology.IsLocalSite.Γ_isLeftAdjoint
+CategoryTheory.Limits.productUniqueIso_inv_π
+CategoryTheory.Limits.productUniqueIso_inv_π_assoc
+CategoryTheory.Limits.ι_coproductUniqueIso_hom
+CategoryTheory.Limits.ι_coproductUniqueIso_hom_assoc
+CategoryTheory.shrinkCoyoneda_obj_map
+CategoryTheory.shrinkYoneda_obj_map

Increase in strong tech debt: (relative, absolute) = (1.00, 0.00)
Current number Change Type (strong)
4524 1 backward.defeqAttrib.useBackward
Increase in weak tech debt: (relative, absolute) = (1.00, 0.00)
Current number Change Type (weak)
4982 1 exposed public sections

Current commit 335f3bdcb4
Reference commit 8a9a2284f0

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@joelriou

Copy link
Copy Markdown
Contributor

Now that we have an API for fiber functors, I think we should use it.
If you import Mathlib.CategoryTheory.Sites.Point.OfIsCofiltered, then the following compiles:

noncomputable def LocalSite.point
    [LocallySmall.{w} C] [J.IsLocalSite] : Point.{w} J :=
  Point.ofIsCofiltered (N := Discrete (PUnit.{w + 1}))
    (Discrete.functor (fun _ ↦ ⊤_ C)) (by
      rintro X S hS ⟨⟨⟩⟩ (f : ⊤_ C ⟶ X)
      exact ⟨_, _, LocalSite.from_terminal_mem_of_mem J f hS, ⟨.unit⟩, 𝟙 _, 𝟙 _, by simp⟩)

The corresponding fiber functor identifies to the global section functors, and the right adjoint functor (the skyscraper sheaf functor) is defined in Mathlib/CategoryTheory/Sites/Point/Skyscraper.lean.

@joelriou joelriou added the awaiting-author A reviewer has asked the author a question or requested changes. label Jun 27, 2026
Comment thread Mathlib/CategoryTheory/Sites/LocalSite.lean Outdated
Comment thread Mathlib/CategoryTheory/ShrinkYoneda.lean Outdated
@mathlib-dependent-issues mathlib-dependent-issues Bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Jun 29, 2026
@mathlib-dependent-issues mathlib-dependent-issues Bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Jun 30, 2026
@mathlib-dependent-issues

Copy link
Copy Markdown

This PR/issue depends on:

Comment thread Mathlib/CategoryTheory/Limits/Shapes/IsTerminal.lean Outdated
Comment thread Mathlib/CategoryTheory/Limits/Shapes/IsTerminal.lean Outdated
Comment thread Mathlib/CategoryTheory/Sites/LocalSite.lean Outdated
Comment thread Mathlib/CategoryTheory/Sites/LocalSite.lean Outdated
Comment thread Mathlib/CategoryTheory/Sites/LocalSite.lean Outdated
Comment thread Mathlib/CategoryTheory/Limits/Shapes/Products.lean Outdated
Comment thread Mathlib/CategoryTheory/Limits/Shapes/Products.lean Outdated
Co-authored-by: Christian Merten <christian@merten.dev>
Comment on lines +832 to +835
@[simp]
lemma productUniqueIso_hom [Unique β] (f : β → C) : (productUniqueIso f).hom = Pi.π f default :=
rfl

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

splice-bot maintainer merge

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split PR created and commented

Split off the changes to Mathlib/CategoryTheory/Limits/Shapes/Products.lean in #41202 and posted a comment via splice-bot command maintainer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author A reviewer has asked the author a question or requested changes. t-category-theory Category theory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants